$(document).ready(function(){
$('#nav').find('.active').next().css('display','block');
var left=[11,-47,-76,-206];
$('#nav').children('li').on('mouseover',function(){
	
	$(this).find('.nav-child').css('display','block').css('left',left[$(this).index()]);
	$(this).siblings().find('.nav-child').css('display','none');

});
$('#nav').children('li').on('mouseout',function(){
	$('.nav-child').css('display','none');
	$('#nav').find('.active').next().css('display','block');
});

});




	function SDMenu(id) {
	if (!document.getElementById || !document.getElementsByTagName)
		return false;
	this.menu = document.getElementById(id);
	this.submenus = this.menu.getElementsByTagName("div");
	this.remember = true;
	this.speed = 5;
	this.markCurrent = true;
	this.oneSmOnly = true;
}
SDMenu.prototype.init  = function() {
	var mainInstance = this;
	for (var i = 0; i < this.submenus.length; i++)
		this.submenus[i].getElementsByTagName("span")[0].onclick = function() {
			mainInstance.toggleMenu(this.parentNode);
		};
	if (this.markCurrent) {
		var links = this.menu.getElementsByTagName("a");
		for (var i = 0; i < links.length; i++){
			links[0].className="current";
			
			links[i].onclick = function() {
				var link_t = document.getElementsByTagName("a");
				for (var i = 0; i < link_t.length; i++){
					if(link_t[i].className== "current"){
						link_t[i].className='';
					}
				}
//				this.className = "current";
		}
			//if (links[i].href == sampleframe.location.href) {
			//	links[i].className = "current";
			//	break;
			//}
		}
	}
};
SDMenu.prototype.toggleMenu = function(submenu) {
	if (submenu.className == "collapsed")
		this.expandMenu(submenu);
	else
		this.collapseMenu(submenu);
};
SDMenu.prototype.expandMenu = function(submenu) {
	var fullHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var links = submenu.getElementsByTagName("a");
	for (var i = 0; i < links.length; i++)
		fullHeight += links[i].offsetHeight;
	var moveBy = Math.round(this.speed * links.length);
	
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight + moveBy;
		if (newHeight < fullHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "";
		}
	}, 0);
	this.collapseOthers(submenu);
};
SDMenu.prototype.collapseMenu = function(submenu) {
	var minHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var moveBy = Math.round(this.speed * submenu.getElementsByTagName("a").length);
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight - moveBy;
		if (newHeight > minHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "collapsed";
		}
	}, 0);
};
SDMenu.prototype.collapseOthers = function(submenu) {
	if (this.oneSmOnly) {
		for (var i = 0; i < this.submenus.length; i++)
			if (this.submenus[i] != submenu && this.submenus[i].className != "collapsed")
				this.collapseMenu(this.submenus[i]);
	}
};

	
var myMenu;
window.onload = function(){
	myMenu = new SDMenu("my_menu");
	myMenu.init();
	var firstSubmenu = myMenu.submenus[0];
	myMenu.expandMenu(firstSubmenu);
};




//  	作者：1352371565@qq.com
//  	时间：2017-08-19
//  	描述：选择列表js

	
			$(function() {
				var $div_li = $(".tab_menu ul li"); //找出样式tab_menu 中的 ul li
				$div_li.click(function() { //找出样式tab_menu 中的 ul li 点击运行
					$(this).addClass("selected")
						.siblings().removeClass("selected");
					var index = $div_li.index(this);
					$("div.tab_box > div")
						.eq(index).show()
						.siblings().hide();
				}).hover(function() {
					$(this).addClass("hover");
				}, function() {
					$(this).removeClass("hover");
				})
			})




//<!--
//  	作者：1352371565@qq.com
//  	时间：2017-08-19
//  	描述：广告图轮播js
//  -->
			//1.根据轮播图片个数生成对应数量的控制按钮
			//2.通过left属性让ul向左移动，对应按钮被选中
			//3.通过点击按钮控制显示的图片
			var ul = document.getElementById('pic_box');
			var lis_len = ul.getElementsByTagName('li').length; //图片个数
			var con_tag = document.getElementById('control_tag')
			for(i = 1; i <= lis_len; i++) { //生成按钮
				con_tag.innerHTML += '<span></span>';
			}
			var con_num = con_tag.getElementsByTagName('span'); //获取按钮对象，方便后面更改按钮样式操作
			var inx = 0; //设置下标初始值为0
			// ul向左移动
			// 		left  index     
			// 第一张    0     0     left = -(index*550)+'px'
			// 第二张  -550    1
			// 第三张  -1100   2
			// 第四张  -1650   3
			// 第五张  -2200   4
			// 让它回到第一张  0
			setTimeout(autoplay, 0); //第一次执行
			function autoplay() {
				if(inx >= lis_len) {
					inx = 0;
				}
				play(inx);
				inx++; //下标加1
				setTimeout(autoplay, 2000);
			}
			//点击按钮效果
			for(i = 0; i < lis_len; i++) {
				con_num[i].index = i;
				con_num[i].onclick = function() {
					//this.index = this.innerHTML-1;  //给点击对象设置下标属性
					inx = this.index;
					play(inx);
				}
			}
			//取出公共部分动作 num参数传的是下标
			function play(num) {
				//ul.style.left = -(num*550)+'px';  //左移
				$('#banner ul').animate({
					left: '-' + num * 1024 + 'px',
				}, 1000)
				// $('ul li:eq('+num+')').slideDown();
				for(i = 0; i < lis_len; i++) {
					//先全部没有被选中，再设置当前图片对应的按钮被选中
					con_num[i].className = "leaving";
					con_num[num].className = "selecting";
				}
			}